-
Notifications
You must be signed in to change notification settings - Fork 619
expanding on date histogram docs #11149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
expanding on date histogram docs #11149
Conversation
Signed-off-by: Anton Rubin <[email protected]>
Thank you for submitting your PR. The PR states are In progress (or Draft) -> Tech review -> Doc review -> Editorial review -> Merged. Before you submit your PR for doc review, make sure the content is technically accurate. If you need help finding a tech reviewer, tag a maintainer. When you're ready for doc review, tag the assignee of this PR. The doc reviewer may push edits to the PR directly or leave comments and editorial suggestions for you to address (let us know in a comment if you have a preference). The doc reviewer will arrange for an editorial review. |
Signed-off-by: Anton Rubin <[email protected]>
@sandeshkr419 Could you review this PR? |
| `missing` | Optional | Date string | Treat docs missing the field as if they had this date value. | | ||
| `keyed` | Optional | Boolean | When `true`, returns buckets as an object keyed by the formatted date string. | | ||
| `order` | Optional | Object | Sort buckets by `_key` or `_count`, ascending or descending. | | ||
| `script` | One of the following is required: `field` or `script` | Object | Optional script to compute the value to bucket on. Use with care; scripts add overhead. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional script to compute the value to bucket on. Since the scripts are operated to modify each value, they add overhead and should be used cautiously.
|
||
## Example: Scripted value source | ||
|
||
You can use Painless script to manipulate the values in multiple ways. For example, use the following request to emit the bucket value in epoch milliseconds. This behaves the same as field: "timestamp", but shows the correct return type for scripts: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use a Painless script to dynamically generate or modify the date value used for bucketing in a date_histogram. This provides flexibility for handling complex date logic at query time.
A date_histogram aggregation does not work with date objects or strings directly. It requires a single, numerical value to represent each document's timestamp.
This value must be a long integer representing epoch milliseconds (the number of milliseconds that have passed since 00:00:00 UTC on January 1, 1970).
Any script you provide must return a value of this type. The following example with script behaves the same as example with field: "timestamp", but generates the correct return type for date field:
Signed-off-by: Anton Rubin <[email protected]>
Description
expanding on date histogram docs
Version
all
Checklist
For more information on following Developer Certificate of Origin and signing off your commits, please check here.